package com.leetcode.shuzu;

import java.util.Arrays;

public class MoveZeroesTest {
    public static void main(String[] args) {
        int[] nums = {0,1,0,3,12};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }

    public static void moveZeroes(int[] nums) {
        int fast = 0;
        int slow = 0;
        int n = nums.length;
        while(fast < n){
            if(nums[fast] != 0){
                swap(nums,fast,slow);
                slow++;
            }
            fast++;
        }
    }

    private static void swap(int[] nums,int fast, int slow) {
        int temp = nums[fast];
        nums[fast] = nums[slow];
        nums[slow] = temp;
    }
}
